package com.njust.controller;

import com.njust.form.HeightRequest;
import com.njust.form.RequestGear;
import com.njust.form.SlotForm;
import com.njust.form.TodayQueryForm;
import com.njust.service.GearService;
import com.njust.service.TablesService;
import com.njust.service.TrainService;
import com.njust.vo.ResultVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zjwpro@foxmail.com
 * @date 2018/1/9 下午10:36
 */
@RestController
@RequestMapping("/analyze")
@Api("数据分析模块")
public class AnalyzeController {
    @Autowired
    private GearService gearService;

    @Autowired
    private TrainService trainService;

    @Autowired
    private TablesService tablesService;

    /**
     * 槽楔趋势查询分析表
     *
     * @param slotForm
     * @return
     * @throws ParseException
     */
    @ApiOperation(value = "槽楔趋势查询分析表")
    @PostMapping("/slot/tendency")
    public ResultVO SlotTrendencyTable(@RequestBody SlotForm slotForm) throws ParseException {
        ResultVO resultVO = gearService.slotTrendencyQuery(slotForm);
        return resultVO;
    }

    /**
     * 齿高趋势查询分析(气隙)
     * @param requestGear 从前台传过来的json对象。
     * @return
     */
    @ApiOperation(value="齿高趋势查询")
    @PostMapping("/gear/tendency")
    public ResultVO getGearByCondition(@RequestBody RequestGear requestGear) throws ParseException {
        ResultVO resultVo = tablesService.getGearInfoByCondition(requestGear);
        return resultVo;
    }

    /**
     * 齿高定值查询分析
     * @param queryForm
     * @return
     */
    @ApiOperation(value="齿高定值查询分析")
    @PostMapping("/gear/value")
    public ResultVO TodayQuery(@RequestBody TodayQueryForm queryForm) throws ParseException {
        ResultVO resultVO = trainService.TodayQuery(queryForm);
        return resultVO;
    }

    @ApiOperation(value="电机历史高度对比")
    @PostMapping("/gear/gearDifference")
    public ResultVO heightDifference(@RequestBody HeightRequest heightRequest) throws ParseException {
        return trainService.heightDifference(heightRequest);

    }

    @ApiOperation(value="电机历史高度对比报表查询")
    @PostMapping("/gear/todayDifference")
    public ResultVO SearchHeightDifference(@RequestBody HeightRequest heightRequest) throws ParseException {
        return trainService.findHeightDiffer(heightRequest);
    }




}
